package controller;


import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;

@WebServlet("/ABCServlet")
public class ABCServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

  
    public ABCServlet() {
       System.out.println("执行get结构方法");
    }


	public void init(ServletConfig config) throws ServletException {
		System.out.println("执行get的init初始化方法");
	}

	
	public void destroy() {
		System.out.println("执行get的destroy销毁方法");
	}

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("执行get的doGet方法");
		System.out.println("项目部署路径" + request.getServletContext().getRealPath(""));
		System.out.println("执行get的doGet执行完毕");
		
		String name = request.getParameter("name");
		String[] hobbies = request.getParameterValues("hobbies");
		System.out.println("你好" + name);
		System.out.println("你的兴趣爱好有:");
		for (String hobby : hobbies) {
			System.out.println(hobby);
		}
		System.out.println("执行get的doGet执行完毕");
		request.setCharacterEncoding("UTF-8");
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
